<?php
/**
 * Created by PhpStorm.
 * User: edmmss
 * Date: 2018/12/12
 * Time: 18:08
 */

namespace app\modules\command;


class Receiver
{
    private $_enableDate = false;

    private $_output = [];

    public function write(string $str)
    {
        if ($this->_enableDate) {
            $str .= '[' . date('Y-m-d') . ']';
        }

        $this->_output[] = $str;
    }

    public function getOutput(): string
    {
        return join("\n", $this->_output);
    }

    public function enableDate()
    {
        $this->_enableDate = true;
    }

    public function disableDate()
    {
        $this->_enableDate = false;
    }
}